home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000056_icon-group-sender _Fri Feb 28 20:57:37 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Mon, 3 Mar 1997 08:32:40 MST
  2. Date: Fri, 28 Feb 1997 20:57:37 -0600 (CST)
  3. Message-Id: <199703010257.UAA23596@dfw-ix9.ix.netcom.com>
  4. X-Sender: bobalex@popd.ix.netcom.com
  5. X-Mailer: Windows Eudora Pro Version 2.1.2
  6. Mime-Version: 1.0
  7. Content-Type: text/plain; charset="us-ascii"
  8. To: Stuart Robinson <srobinso@reed.edu>,
  9.         Icon Group <icon-group@cs.arizona.edu>
  10. From: Bob Alexander <bobalex@ix.netcom.com>
  11. Subject: Re: Help with Program
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13. Status: RO
  14. Content-Length: 1723
  15.  
  16. Here's a little Icon program that does what you asked, I think.  I'll leave
  17. it as an exercise to add little improvements like a "local" declaration (not
  18. all that helpful in such a small program, but a good idea as complexity
  19. increases), and maybe comments (it's not a necessary part of the Icon
  20. culture to write cryptic programs).  If any questions, feel free to ask.
  21. --- Bob
  22.  
  23. procedure main()
  24.   lineNbr := 0
  25.   while line := read() do line ? {
  26.     lineNbr +:= 1
  27.     (nbr := tab(many(&digits)) &
  28.         tab(many(' \t')) &
  29.         letter1 := move(1) &
  30.         tab(many(' \t')) &
  31.         letter2 := move(1) &
  32.         pos(0)) | write("*** Line ",lineNbr," is invalid")
  33.     if nbr === lastNbr then
  34.       write(lineNbr - 1,"-",lineNbr,"   ",
  35.         lastLetter1,letter1,"    ",lastLetter2,letter2)
  36.     lastNbr := nbr; lastLetter1 := letter1; lastLetter2 := letter2
  37.   }
  38. end
  39.  
  40. >I have a number of texts each line of which has been coded for three types
  41. >of information.  Each line of the text will be assigned a number and a
  42. >code for two categories. The numbers are just whole numbers (raning from 1
  43. >to 20 or so) and each category has four members (say, ABCD and WXYZ). 
  44. >Here is an example text: 
  45. >
  46. >1 A X
  47. >1 A Y
  48. >1 B Y
  49. >2 B Y
  50. >
  51. >Note that some successive lines share an index number (as in lines 1 and
  52. >2 and 2 and 3).  When that is the case, I would like the program to
  53. >output the members of each category for the matched lines, as below:
  54. >
  55. >1-2    AA    XY
  56. >2-3    AB    YY
  57. >
  58. >That is it.  There are some additional complications, but I think that I
  59. >can solve those at a later date.  At the moment, this sort of
  60. >rough-and-ready analysis is all I need.
  61. >
  62. >Any suggestions?  Thanks in advance.
  63. >
  64. >--Stuart <srobinso@reed.edu>
  65. >
  66. >
  67. >
  68. >
  69.  
  70.